#pragma once

#include <string>

template <typename T>
class BlockingQueuePro;
class SqlOperation;
namespace sql
{
    class Driver;
    class Connection;
    class ResultSet;
    class SQLException;
} // namespace sql
class MySQLWorker;

struct MySQLConnInfo {
    explicit MySQLConnInfo(const std::string &db,const std::string &url);
    std::string user_;
    std::string password_;
    std::string database_;
    std::string url_;
};

class ConnObject
{
public:
    ConnObject(const std::string &db,const std::string &url,BlockingQueuePro<SqlOperation*> &task_queue);
    ~ConnObject();

    void Open();
    void Close();

    sql::ResultSet* QueryDatabase(std::string &sql);

private:
    void HandlerException(const sql::SQLException &e);

    sql::Driver *driver_;
    sql::Connection *conn_;
    MySQLWorker* workthread_;
    MySQLConnInfo info_;
};


